<template>
    <div class="right">
        <div class="content-right-box">
            <div class="title">
                <img src="../../../assets/imgx/title-bg-image.png" alt="" />
                <div class="">
                    故障信息栏 <span>FAULT INFORMATION BAR</span><img src="../../../assets/icon/title-tail.png" alt="" />
                </div>
            </div>
            <div class="combo-box box-fault">
                <p></p>
                <p></p>
                <p></p>
                <p></p>
                <p></p>
                <p></p>
                <p></p>
                <p></p>
                <div class="fault-info">
                    <div class="content-right-box-item-1">

                        <template v-if="faultList.length">
                            <div v-for="( item, i ) of  faultList " class="item" :key="i">
                                <div class="flex-between piece">
                                    <div class="info-content">
                                        <div>{{ item.createTime1 + " " + item.exceptMessageCn }}</div>
                                        <div>{{ item.description }}</div>
                                    </div>
                                    <div class="processed" v-if="item.exceptStatus === 'DONE'">
                                        <img src="../../../assets/icon/processed.png" alt="" />
                                        已处理
                                    </div>
                                    <div class="untreated" v-if="item.exceptStatus === 'TODO'">
                                        <div class="flex-center">
                                            <img src="../../../assets/icon/untreated.png" alt="" /> 未处理
                                        </div>
                                        <div class="btn-view" @click="LookPlan(item)">查看方案</div>
                                    </div>
                                </div>
                                <div class="bottom" v-if="i + 1 !== faultList.length"></div>
                            </div>
                        </template>
                        <template v-else>
                            <div>
                                <div class="flex-between piece">
                                    <div class="info-content-off">
                                        暂无数据
                                    </div>
                                </div>
                                <div class="bottom"></div>
                            </div>
                        </template>
                    </div>
                </div>
            </div>
        </div>
        <div class="content-right-box box1right" style="margin-top: 54px">
            <div class="title">
                <img src="../../../assets/imgx/title-bg-image.png" alt="" />
                <div class="">
                    设备分析栏 <span>DEVICE ANALYSIS FIELD</span><img src="../../../assets/icon/title-tail.png" alt="" />
                </div>
            </div>

            <div class="content-right-box-item">
                <template v-if="analysisArrAy.length">

                    <div v-for="( item, index ) in  analysisArrAy " :key="index" class="device-info">
                        <img src="../../../assets/imgx/device-analyis.png" alt="" />
                        <p>
                            {{ item.messageCn }}
                        </p>
                    </div>


                </template>
                <template v-else>
                    <div class="device-info-off">
                        <img src="../../../assets/imgx/device-analyis.png" alt="" />
                        <div class="title">
                            暂无数据
                        </div>
                    </div>
                </template>
            </div>
        </div>
    </div>
</template>
<script>
import {
    getRecordExceptList,
    equipmentAnalysis
} from "@/api/homeModeApi/index"
export default {
    data() {
        return {
            faultList: [],
            analysisArrAy: [],
            time2: "",
            timerSum: ""
        }
    },
    mounted() {
        // this.hourFun();
        this.getRecordList();
        this.deviceAnalysisColumn()
        // 清空接口重新20秒后重新请求
        this.timerSum = setInterval(() => {
            clearInterval(this.timer)
            this.hourFun()
        }, 200000)
    },
    beforeDestroy() {
        clearInterval(this.time2)
        clearInterval(this.timerSum)
    },
    methods: {
        hourFun() {
            this.time2 = setInterval(() => {
                this.getRecordList()
                this.deviceAnalysisColumn()
            }, 3000)
        },


        //设备分析栏
        deviceAnalysisColumn() {
            equipmentAnalysis().then(res => {
                if (res.code == 200) {
                    this.analysisArrAy = res.data
                }
            })
        },
        //故障信息栏
        getRecordList() {
            getRecordExceptList().then(res => {
                if (res.code == 200) {
                    this.faultList = res.data;
                }
            })
        },
        LookPlan(item) {
            this.$emit('LookPlan', item)
        }
    },
}
</script>
<style lang="less" scoped>
.info-content {
    display: flex;
    flex-direction: column;
}


.box1right {
 height: 500px !important;
}
.right {
    width: 100%;
    height: 100%;

    .content-right-box {
        height: 45%;
        display: flex;
        flex-direction: column;
        justify-content: space-between;

        .title {
            position: relative;
            height: 42px;

            img:nth-child(1) {
                width: 100%;
                height: 100%;
            }

            div {
                color: #fff;
                position: absolute;
                top: 12%;
                left: 15%;
                font-size: 18px;

                span {
                    margin-left: 5px;
                    color: #1779b9;
                    font-size: 14px !important;
                }

                img {
                    margin-left: 10px;
                }
            }
        }



        .content-right-box-item {
            height: 85%;
            width: 409px;
            overflow: auto;
        }
    }

    .fault-info {
        height: 100%;
        vertical-align: middle;

        .content-right-box-item-1 {
            width: 97%;
            height: 356px;
            overflow: auto;
            padding: 5px;

            .item {
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
            }
        }
    }

    .fault-info {
        font-family: "思源黑体", "Microsoft YaHei";
        font-size: 35px;

        .piece {
            // // opacity: 0.2;
            // border-bottom: 1px solid ;
            // border-image: linear-gradient(to bottom, #010F2F, #FFFFFF) 1;
        }

        .bottom {
            width: 80%;
            height: 1px;
            border-bottom: 1px solid #ccc;
            border-bottom: 1px solid;
            border-image: linear-gradient(10deg, rgba(255, 255, 255, 0.00) 0%, #ccc 50%, rgba(255, 255, 255, 0.00) 99%) 2 2 2 2;
        }

        .info-content-off {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            width: 100%;
            font-size: 16px;
            color: white;
            height: 44px;
        }

        .info-content {

            width: 280px;

            div {
                width: 100%;
            }

            div:nth-child(1) {
                font-size: 15px;
                font-family: SourceHanSansCN-Normal, SourceHanSansCN;
                font-weight: 400;
                color: #a5f2ff;
                line-height: 29px;
            }

            div:nth-child(2) {
                font-size: 14px;
                font-family: SourceHanSansCN-Light, SourceHanSansCN;
                font-weight: 300;
                color: #e0eefc;
                line-height: 29px;
            }
        }

        .processed {
            width: 76px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-size: 15px;
            font-family: SourceHanSansCN-Normal, SourceHanSansCN;
            font-weight: 400;
            color: #39e9a3;

            img {
                width: 22px;
                height: 22px;
            }
        }

        .untreated {
            font-size: 15px;
            font-family: SourceHanSansCN-Normal, SourceHanSansCN;
            font-weight: 400;
            color: #f26463;

            width: 75px;
            height: 22px;
            display: flex;
            flex-direction: column;
            justify-content: center;

            .flex-center {
                display: flex;
                align-items: center;
                justify-content: space-between;
            }



            .btn-view {

                cursor: pointer;
                width: 76px;
                height: 28px;
                background: #011A41;
                opacity: 1;
                text-align: center;
                color: white;
                line-height: 28px;
                border: 1px solid #2B7FAF;
                margin: 5px 10px 0px 0px;
            }
        }
    }

    .device-info-off {
        width: 409px;
        height: 70px;
        font-size: 14px;
        font-family: SourceHanSansCN-Light, SourceHanSansCN;
        font-weight: 300;
        color: #7B8EA1;
        position: relative;

        img {
            width: 100%;
            position: absolute;

        }

        .title {
            position: absolute;
            top: 36%;
            left: 43%;

            div {
                font-size: 18px;
                color: #ffffff;
                font-weight: 400;

                span {
                    color: #2062a5;
                    font-weight: 400;
                    font-size: 14px !important;
                }

            }
        }
    }

    .device-info {
        position: relative;
        font-size: 35px;
        width: 409px;
        height: 70px;
        margin-bottom: 11px;
        img {
            width: 100%;
            height: 100%;
        }

        p {
            position: absolute;
            top: 15px;
            left: 68px;
            width: 80%;
            font-size: 14px;
            font-family: SourceHanSansCN-Light, SourceHanSansCN;
            font-weight: 300;
            color: white;
            line-height: 22px;
        }
    }

}
</style>